<template>
  <el-dialog title="三要素查询&运行商信息" :visible.sync="dialogVisible" width="1100px">
    <h2>{{ cert_name }}{{type==1?'三网详情':'运行商信息'}} </h2>
    <br>
    <el-row>
      <el-col :span="8">报告生成时间：{{start_at }}</el-col>
      <el-col :span="8">订单ID：{{ this.editItem?.id || this.editItem?.order_id}}</el-col>
      <el-col :span="8">手机号：{{ mobile  }}</el-col>
    </el-row>
    <div v-if="type==1">
      <br>
      <el-descriptions title="运营商三要素核验" direction="vertical" :column="3" border>
        <el-descriptions-item label="运营商归属地">{{ result1 }}</el-descriptions-item>
      </el-descriptions>
      <br>
      <el-descriptions title="运营商号码在网时长查询" direction="vertical" :column="3" border>
        <el-descriptions-item label="归属运营商">{{ result2.phoneType==1?'移动': result2.phoneType==2?'联通':'电信' }}</el-descriptions-item>
        <el-descriptions-item label="在网时长">{{ result2.onlineTime }}/月</el-descriptions-item>
        <el-descriptions-item label="操作人">{{ result2.operator==cmcc?'移动':result2.operator==cucc?'联通':'电信' }}</el-descriptions-item>
      </el-descriptions>
      <br>
      <el-descriptions title="运营商在网状态查询" direction="vertical" :column="3" border>
        <el-descriptions-item label="归属运营商">{{ result3.phoneType==1?'移动': result3.phoneType==2?'联通':'电信'}}</el-descriptions-item>
        <el-descriptions-item label="在网状态">{{ result3.onlineStatus==0?'正常':result3.onlineStatus==1?'停机':result3.onlineStatus==2?'在网不可用':result3.onlineStatus==3?'销号':result3.onlineStatus==4?'预售号码':'号码异常' }}</el-descriptions-item>
        <el-descriptions-item label="操作人">{{ result3.operator==cmcc?'移动':result3.operator==cucc?'联通':'电信' }}</el-descriptions-item>
      </el-descriptions>
      <br>
    </div>
    <div v-else>
      <br>
      <el-descriptions title="运营商信息" direction="vertical" :column="3" border>
        <el-descriptions-item label="二要素认证">{{list3.resultMessage}}</el-descriptions-item>
        <el-descriptions-item label="三要素认证">{{list4.resultMessage}}</el-descriptions-item>
        <el-descriptions-item label="手机在网时长">{{ list5.resultMessage+'月' }}</el-descriptions-item>
        <el-descriptions-item label="在网状态">{{ list6.isp=='CM'?'中国移动-':list6.isp=='CT'?'中国电信-':list6.isp=='CU'?'中国联通-':'暂无-'}}{{ list6.resultMessage }}</el-descriptions-item>
        <el-descriptions-item label="运营商归属信息">{{ list1.province+'-'+list1.city}}</el-descriptions-item>
        <el-descriptions-item label="近3个月总停机次数">{{ list8.resultMessage+'次' }}</el-descriptions-item>
        <el-descriptions-item label="近3个月通话时长均值">{{ list9.resultMessage+'分钟' }}</el-descriptions-item>
        <el-descriptions-item label="近3个月平均月账单金额">{{ list7.resultMessage+'元'}}</el-descriptions-item>
        <el-descriptions-item label="近3个月流量均值">{{ list2.resultMessage+'M' }}</el-descriptions-item>
      </el-descriptions>
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="dialogVisible = false">关闭</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { getOperatorData,getMobileData } from '@/api/order'
export default {
  props: {
    editItem: {
      type: Object,
      default: () => ({})
    },
    type:{
      type:Number,
      default:0
    }
  },
  data() {
    return {
      dialogVisible: false,
      cert_name: '',
      start_at: '',
      level: '',
      mobile:'',
      result1:'',
      result2:{},
      result3:{},
      list1:{}, //手机归属
      list2:{}, //流量均值
      list3:{}, //二要素
      list4:{}, //三要素
      list5:{}, //在网时长
      list6:{}, //在网状态
      list7:{}, //月账单
      list8:{}, //停机
      list9:{} //通话
    }
  },
  watch: {
    dialogVisible(val) {
      if (val) {
        this.$nextTick(() => {
          this.getList()
        })
      }
    }
  },
  methods: {
    getList() {
      let params={
        orderId:this.editItem?.id || this.editItem?.order_id,
        cert_name:this.editItem?.authentic?.cert_name || this?.editItem?.cert_name,
        cert_no:this.editItem?.authentic?.cert_no|| this.editItem?.cert_no,
        mobile:this.editItem.mobile
      }
      if(this.type==1){
        getOperatorData(params).then(res=>{
          this.start_at=res.start_at
          this.cert_name=res.cert_name
          this.cert_no=res.cert_no
          this.mobile=res.mobile
          this.result1=res.message
          this.result2=res.result2.data
          this.result3=res.result3.data
        })
      }else{
        // 请求运行商信息数据
        getMobileData(params).then(res=>{
          this.start_at=res.start_at
          this.cert_name=res.cert_name
          this.cert_no=res.cert_no
          this.mobile=res.mobile
          this.list1=res.result.data
          this.list2=res.result2.data
          this.list3=res.result3.data
          this.list4=res.result4.data
          this.list5=res.result5.data
          this.list6=res.result6.data
          this.list7=res.result7.data
          this.list8=res.result8.data
          this.list9=res.result9.data
          console.log(res);
        })
      }
    }
  }
}
</script>

<style lang="scss" scoped></style>
